package com.download.manager;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.text.TextUtils;
import android.widget.Toast;

import androidx.annotation.Nullable;

public class M3u8DownLoadService extends Service {

    public static String URL_VALE="down_load_url";

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        if(intent!=null && intent.hasExtra(URL_VALE) && !TextUtils.isEmpty(intent.getStringExtra(URL_VALE))){
            String url=intent.getStringExtra(URL_VALE);
            if(url.contains(".m3u8")){
                String res=M3u8DownLoadManager.getInstance().startDownLoadUrl(url);
                Toast.makeText(getApplicationContext(),res,Toast.LENGTH_SHORT).show();
            }else {
                //普通下载
                Toast.makeText(getApplicationContext(),"链接不合法",Toast.LENGTH_SHORT).show();
            }
        }
        return super.onStartCommand(intent, flags, startId);
    }

}